package edu.arizona.mindseye.swing;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;

import edu.arizona.mindseye.event.Event;
import edu.arizona.mindseye.event.EventManager;
import edu.arizona.mindseye.event.enums.EventType;

public class MoviePanel extends JPanel {

	private JButton _directory;
	private JButton _load;

	private JButton _showBehaviors;
	private JButton _save;
	
	private DisplayBehaviorsDialog _dialog;
	
	public MoviePanel() { 
		super();
		
		addComponents();
		addListeners();
	}
	
	private void addComponents() { 
		setLayout(new FlowLayout());
		
		_directory = new JButton("Set Directory");
		_load = new JButton("Load Movie");
		
		_showBehaviors = new JButton("Show Behaviors");
		_save = new JButton("Save");
		
		_dialog = new DisplayBehaviorsDialog();
		
		add(_directory);
		add(_load);
		add(_showBehaviors);
		add(_save);
	}
	
	private void addListeners() { 
		_directory.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				
			} 
		});
		
		_load.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
			} 
		});
		
		_showBehaviors.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				_dialog.setVisible(true);
			} 
		});
		
		_save.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				Event event = new Event(EventType.DO_SAVE_ANNOTATIONS);
				EventManager.inst().dispatch(event);
			} 
		});
	}
}
